import fetch from 'common/src/utils/fetch'

/**
 * 查询成绩记录方式列表
 */
export function getScoreRecordList (data = {}) {
  return fetch({
    url: '/api/scoremanagementservice/scoreRecordMode/listScoreSetting',
    method: 'post',
    data
  })
}
/**
 * 
 * 新增成绩记录方式 
 */
export function addScoreRecord (data) {
  return fetch({
    url: '/api/scoremanagementservice/scoreRecordMode/insertOrUpdateScoreSet',
    method: 'post',
    data
  })
}
/**
 * 
 * 删除成绩记录方式列表
 * 发送示例 /api/scoremanagementservice/scoreRecordMode/deleteScoreSetById?ids=1,24  参数:主键id的字符串拼接
 */
export function deleteRecord (data) {
  return fetch({
    url: '/api/scoremanagementservice/scoreRecordMode/deleteScoreSetById?ids=' + data,
    method: 'delete'
  })
}
//查询全局设置
export function initScoreGlobalSetting (data = {}) {
  return fetch({
    url: '/api/scoremanagementservice/scoreGlobalSetting/initScoreGlobalSetting',
    method: 'GET',
    data
  })
}
//保存全局设置
export function saveScoreGlobalSetting (data = {}) {
  return fetch({
    url: '/api/scoremanagementservice/scoreGlobalSetting/saveScoreGlobalSetting',
    method: 'POST',
    data
  })
}
// 课程白名单
export function listScoreCourseWhitePage (data = {}) {
  return fetch({
    url: '/api/scoremanagementservice/scoreCourseWhite/listScoreCourseWhitePage',
    method: 'POST',
    data
  })
}
//查询课程信息
export function findCourseByCourseCode (data = {}) {
  return fetch({
    url: '/api/scoremanagementservice/scoreCourseWhite/findCourseByCourseCode',
    method: 'GET',
    params: data
  })
}
//保存白名单
export function saveScoreCourseWhite (data = {}) {
  return fetch({
    url: '/api/scoremanagementservice/scoreCourseWhite/saveScoreCourseWhite',
    method: 'POST',
    data
  })
}
// 删除白名单
export function batchDelScoreCourseWhite (data) {
  return fetch({
    url: `/api/scoremanagementservice/scoreCourseWhite/batchDelScoreCourseWhite?ids=${data}`,
    method: 'DELETE'
  })
}

/**
 * 导出 
 * url:导出路径，params:导出所需参数
 */
export function derive(url,params={}) {
      if(!url) return ;
     let string="";
        for(var key in params){
            string+=`${key}=${params[key]?params[key]:""}&`
        }
    let restApi=`${url}?${string.substring(0,string.length-1)}`;
    window.location.href=restApi;
}   
